package com.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

//@Configuration
public class Securityconfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        String user="zhangsan";
        String password="123456";
        BCryptPasswordEncoder encoder=getBCP();
        //加密，使用hs256进行加密
        password=encoder.encode(password);
        auth.inMemoryAuthentication().withUser(user).password(password).roles("aaa");
    }
    //密码加密
//    @Bean
    BCryptPasswordEncoder getBCP(){
        return new BCryptPasswordEncoder();
    }
}
